package com.gujia.async;

import com.alibaba.fastjson.JSONObject;
import com.gujia.util.JedisAdapter;
import com.gujia.util.RedisKeyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by GuJia on 2017/7/9.
 */
@Component
public class EventProducer {

    @Autowired
    JedisAdapter jedisAdapter;

    public boolean fireEvent(EventModel eventModel ){
        try{

            String json = JSONObject.toJSONString(eventModel);
            String key = RedisKeyUtil.getEventQueueKey();

            jedisAdapter.lpush(key,json);
            return true;

        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}
